package com.example.administrator.x2picturetransliteration.Home.Adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.example.administrator.x2picturetransliteration.Base.BaseListViewAdapter;
import com.example.administrator.x2picturetransliteration.Bean.CommonProblemBean;
import com.example.administrator.x2picturetransliteration.Home.Activity.CommonProblemDetailsActivity;
import com.example.administrator.x2picturetransliteration.R;

import java.util.List;

/**
 * 常见问题
 * Created by Administrator on 2019/8/26.
 */

public class CommonProblemAdapter extends BaseListViewAdapter{

    private Context context;
    private List<CommonProblemBean> mData;

    public CommonProblemAdapter(Context context,List<CommonProblemBean> mData) {
        super(context);

        this.context = context;
        this.mData = mData;
    }

    @Override
    public int getLayoutView() {
        return R.layout.home_item_common_problem;
    }

    @Override
    public int mCount() {
        return mData.size();
    }

    @Override
    public void logic(ViewHolder mViewHolder, View view, final int position) {

        final IViewHolder mIViewHolder = (IViewHolder)mViewHolder;

        mIViewHolder.text.setText("Q" + position + "：" + mData.get(position).getTitle());

        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                CommonProblemDetailsActivity.startCommonProblemDetailsActivity(context,mData.get(position).getId());

            }
        });

    }

    @Override
    public ViewHolder InstantiationView(View mview) {

        IViewHolder mIViewHolder = new IViewHolder();

        mIViewHolder.text = mview.findViewById(R.id.text);

        return mIViewHolder;
    }

    private class IViewHolder extends ViewHolder{

        TextView text;

    }
}
